package cn.cnsy123.blog.application.http.request;

import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * @author yangpengfei
 * @description 博客客户端-用户注册请求信息
 * @date 2019-10-13 18-01-24
 */
public class UserRegisterRequest {

    /**
     * 用户邮箱
     */
    @NotBlank(message = "需要通过邮件激活账户，请输入邮箱地址")
    @Email(message = "请检查邮箱地址是否正确")
    private String userMail;

    /**
     * 用户手机号
     */
    @NotBlank(message = "激活账户需要手机短信验证，请输入手机号码")
    @Length(min = 11,max = 11,message = "手机号位数不对")
    @Pattern(regexp = "^[1](([3|5|8][\\d])|([4][4,5,6,7,8,9])|([6][2,5,6,7])|([7][^9])|([9][1,8,9]))[\\d]{8}$",message = "请检查手机号码是否正确")
    private String userPhone;

    /**
     * 用户名
     */
    @NotBlank(message = "请输入登录博客的用户名")
    @Length(min = 4,max = 20,message = "用户名长度超出或者太小")
    @Pattern(regexp = "^[^\u4e00-\u9fa5]{0,}$",message = "用户名不能包含汉字")
    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]{4,20}$",message = "用户名不能包含除“_”外的符号或不能以数字开头")
    private String userName;

    /**
     * 用户昵称
     */
    @NotBlank(message = "请输入用户昵称")
    @Length(min = 4,max = 20,message = "昵称长度超出或者太小")
    @Pattern(regexp = "^[\u4E00-\u9FA5A-Za-z0-9]{4,20}$",message = "昵称只能为字母、数字、汉字的组合")
    private String userNickName;

    /**
     * 用户密码
     */
    @NotBlank(message = "请输入登录密码")
    @Length(min = 8,max = 20,message = "用户密码长度超出或者太小")
    @Pattern(regexp = "^[^\u4e00-\u9fa5]{0,}$",message = "密码不能包含汉字")
    @Pattern(regexp = "^[a-zA-Z]\\w{8,20}$",message = "密码只能以字母开始，长度在8-20位，只能包含字母、数字和下划线")
    private String passWord;

    /**
     * 是否同意用户注册协议
     */
    @NotNull(message = "请同意用户注册协议")
    @Pattern(regexp = "^[0-1]$",message = "用户注册协议，只能输入0(同意)或1(拒绝)")
    private String agreeRegisterAgreement;

    public String getUserMail() {
        return userMail;
    }

    public void setUserMail(String userMail) {
        this.userMail = userMail;
    }

    public String getUserPhone() {
        return userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserNickName() {
        return userNickName;
    }

    public void setUserNickName(String userNickName) {
        this.userNickName = userNickName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public String getAgreeRegisterAgreement() {
        return agreeRegisterAgreement;
    }

    public void setAgreeRegisterAgreement(String agreeRegisterAgreement) {
        this.agreeRegisterAgreement = agreeRegisterAgreement;
    }

    public UserRegisterRequest(String userMail, String userPhone, String userName, String userNickName, String passWord, String agreeRegisterAgreement) {
        this.userMail = userMail;
        this.userPhone = userPhone;
        this.userName = userName;
        this.userNickName = userNickName;
        this.passWord = passWord;
        this.agreeRegisterAgreement = agreeRegisterAgreement;
    }

    public UserRegisterRequest() {
    }

    @Override
    public String toString() {
        return "UserRegisterRequest{" +
                "userMail='" + userMail + '\'' +
                ", userPhone='" + userPhone + '\'' +
                ", userName='" + userName + '\'' +
                ", userNickName='" + userNickName + '\'' +
                ", passWord='" + passWord + '\'' +
                ", agreeRegisterAgreement=" + agreeRegisterAgreement +
                '}';
    }
}
